public class Test07 {
        public static int findPeakElement(int[] nums) {

            int left = 0;
            int right = 0;
            while(left<right){
                int mid = left+(right-left)/2;
                if(nums[mid]<nums[mid+1]){
                    left = mid+1;
                }else if(nums[mid]<nums[mid-1]){
                    right = mid-1;
                }else{
                    return mid;
                }
            }
            return left;
        }

    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,1};
       int a =  findPeakElement(arr);
        System.out.println(a);
    }
}
